package com.base.cn.platform.os.service.exam.record;

import com.base.cn.platform.os.entity.exam.record.ExamRecord;
import com.base.cn.platform.os.entity.exam.record.ExamRecordCondition;
import com.base.cn.platform.os.entity.exam.record.UserScoreRanking;
import com.base.cn.platform.os.service.FeignAuthConfig;
import com.base.cn.platform.os.service.exam.ExamBaseService;
import com.github.pagehelper.PageInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 考试记录接口
 *
 * @author s.li
 * @date 2018/12/08
 */
@FeignClient(name = ExamBaseService.appName,configuration = FeignAuthConfig.class)
public interface ExamRecordService extends ExamBaseService {

    /**
     * 生成随堂练习的考试记录
     * @param userId 用户ID
     * @param courseId 课程ID
     * @param catalogId 目录ID
     * @param questionIds 随堂练习试题ID
     * @param name 名称
     * @return 考试记录ID
     */
    @RequestMapping(contextPath + "/createCatalogExam")
    Map<String,Object> createCatalogExam(@RequestParam("userId") BigDecimal userId,
                                         @RequestParam("courseId") BigDecimal courseId,
                                         @RequestParam("catalogId") BigDecimal catalogId,
                                         @RequestParam("questionIds") String questionIds,
                                         @RequestParam("name") String name);

    /**
     * 查询考试记录数量
     * @param examRecord 查询条件
     * @return 数量
     */
    @RequestMapping(contextPath + "/getExamRecordCount")
    BigDecimal getExamRecordCount(@RequestBody Map<String, Object> examRecord);

    /**
     * 再来15道题
     * @param examRecordId 原考试记录ID
     * @return Map<BigDecimal,Object>
     */
    @RequestMapping(contextPath +"/tenFiveQuestion")
    Map<String,Object> tenFiveQuestion(@RequestParam("examRecordId") BigDecimal examRecordId);

    /**
     * 查询开始考试数据
     * @param userId 用户ID
     * @param examRecordId 考试ID
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/newlyExam")
    Map<String,Object> newlyExam(@RequestParam("userId") BigDecimal userId,
                                 @RequestParam("examRecordId") BigDecimal examRecordId);

    /**
     * 提交试卷
     * @param userId 用户ID
     * @param examRecordId 考试记录ID
     * @param status 状态，1退出，2完成
     * @param examTime 考试用时（单位：秒）
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/submitExamRecord")
    Map<String,Object> submitExamRecord(@RequestParam("userId") BigDecimal userId,
                                        @RequestParam("examRecordId") BigDecimal examRecordId,
                                        @RequestParam("status") int status,
                                        @RequestParam("examTime") int examTime);

    /**
     * 通过ID，查询考试记录
     * @param condition 查询条件
     * @return ExamRecord
     */
    @RequestMapping(contextPath + "/findExamRecordById")
    ExamRecord findExamRecordById(@RequestBody Map<String, Object> condition);

    /**
     * 查询考试记录列表
     * @param condition 查询条件
     * @return List<ExamRecord>
     */
    @RequestMapping(contextPath + "/findExamRecordList")
    List<Map<String,Object>> findExamRecordList(@RequestBody Map<String, Object> condition);
    /**
     * 查询考试记录列表
     * @param condition 查询条件
     * @return List<ExamRecord>
     */
    @RequestMapping(contextPath + "/findExamRecordList")
    List<ExamRecord> findExamRecord(@RequestBody Map<String, Object> condition);

    /**
     * 分页查询记录
     * @param condition 查询条件
     * @param currentPage 页码
     * @param pageSize 查询数量
     * @return PageInfo<ExamRecord>
     */
    @RequestMapping(contextPath + "/findExamRecordListPage")
    Map<String,Object> findExamRecordListPage(@RequestBody Map<String, Object> condition,
                                              @RequestParam("currentPage") int currentPage,
                                              @RequestParam("pageSize") int pageSize);

    /**
     * 获取用户作业当年
     * @param condition 查询条件
     * @param currentPage 页码
     * @param pageSize 查询数量
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/findUserTaskExamRecordListPage")
    Map<String,Object> findUserTaskExamRecordListPage(@RequestBody Map<String, Object> condition,
                                                      @RequestParam("currentPage") int currentPage,
                                                      @RequestParam("pageSize") int pageSize);

    /**
     * 创建错题考试记录
     * @param userId 用户ID
     * @param subjectIds 专业ID串
     * @param mode 练习模式 1顺序模式，2随机模式，3高频错题
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/createExamErrorRecord")
    Map<String,Object> createExamErrorRecord(@RequestParam("userId") BigDecimal userId,
                                             @RequestParam("subjectIds") String subjectIds,
                                             @RequestParam("mode") int mode);

    /**
     * 创建考点练习考试记录
     * @param subjectIds 专业ID串
     * @param pointId 考点ID
     * @param userId 用户ID
     * @param type 类型，1-固定15道，2-随机30道
     * @param mode 1.考试模式 2.练习模式
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/createPointExamRecord")
    Map<String,Object> createPointExamRecord(
            @RequestParam("subjectIds") String subjectIds,
            @RequestParam("pointId") String pointId,
            @RequestParam("userId") BigDecimal userId,
            @RequestParam("type") int type,
            @RequestParam("mode") int mode);

    /**
     * 生成真题试卷的考试记录
     * @param examId 试卷ID
     * @param userId 用户ID
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/createExamPaperRecord")
    Map<String,Object> createExamPaperRecord(@RequestParam("examId") BigDecimal examId,
                                             @RequestParam("userId") BigDecimal userId);

    /**
     *  生成自由组卷考试记录
     * @param userId 用户ID
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/createCustomExamRecord")
    Map<String,Object> createCustomExamRecord(@RequestParam("userId") BigDecimal userId);

    /**
     * 完成自评
     * @param userId 用户ID
     * @param examRecordId 试卷记录ID
     * @param isWeb 是否来自前台
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/finishMarkExam")
    Map<String,Object> finishMarkExam(@RequestParam("userId") BigDecimal userId,
                                      @RequestParam("examRecordId") BigDecimal examRecordId,
                                      @RequestParam("isWeb") boolean isWeb);

    /**
     * 查询考试榜 TOP5 之 试卷
     * @param dateList 时间条件列表
     * @return List<ExamUseFiveCount>
     */
    @RequestMapping(contextPath + "/queryExamUseFiveList")
    List<Map<String,Object>> queryExamUseFiveList(@RequestBody List<Date> dateList);

    /**
     * 通过ID，查询考试记录
     * @param condition 查询条件
     * @return ExamRecord
     */
    @RequestMapping(contextPath +"/findExamRecordPractice")
     ExamRecord findExamRecordPractice(@RequestBody Map condition);




    /**
     * 查询随堂练习人数
     * @param param 条件
     * @return List<ExamUseFiveCount>
     */
    @RequestMapping(contextPath +"/queryPracticePassNumber")
    Map queryPracticePassNumber(@RequestBody Map param);


    /**
     * 查询随堂练习记录
     * @param condition 查询条件
     * @param currentPage 页码
     * @param pageSize 查询数量
     * @return PageInfo<ExamRecord>
     */
    @RequestMapping(contextPath + "/findExamRecordPracticeListPage")
    PageInfo<ExamRecord>  findExamRecordPracticeListPage(@RequestBody Map<String, Object> condition,
                                                                           @RequestParam("currentPage") int currentPage,
                                                                           @RequestParam("pageSize") int pageSize);



    /**
     * 分页查询试卷的做题记录
     * @param condition 查询条件
     * @param currentPage 页码
     * @param pageSize 查询数量
     * @return PageInfo<ExamRecord>
     */
    @RequestMapping(contextPath + "/findExamUserRecordListPage")
    Map<String,Object> findExamUserRecordListPage(@RequestBody ExamRecordCondition condition,
                                              @RequestParam("currentPage") int currentPage,
                                              @RequestParam("pageSize") int pageSize);


    @RequestMapping(contextPath+"/queryUserScoreRanking")
    List<UserScoreRanking> queryUserScoreRanking(@RequestBody Map<String, Object> map);
    /**
     * 通过ID，查询考试记录
     * @param condition 查询条件
     * @return ExamRecord
     */
    @RequestMapping(contextPath +"/findExamRecordPracticeList")
    List<ExamRecord> findExamRecordPracticeList(@RequestBody Map condition);

}
